// Micro-interactions for enhanced user experience
@import './variables.scss';

// Button interactions
.el-button {
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
  }
  
  &:active::before {
    width: 300px;
    height: 300px;
  }
  
  &.el-button--primary {
    &:hover {
      animation: buttonPulse 0.3s ease;
    }
  }
  
  &.el-button--success {
    &:hover {
      animation: buttonShake 0.3s ease;
    }
  }
}

// Input field interactions
.el-input {
  .el-input__inner {
    position: relative;
    
    &:focus {
      animation: inputGlow 0.3s ease;
    }
    
    &:valid:not(:placeholder-shown) {
      
      & + .el-input__suffix {
        .el-input__icon {
          color: $success-color;
          animation: checkmark 0.3s ease;
        }
      }
    }
  }
}

// Card hover effects
.el-card,
.module-card,
.stat-card {
  position: relative;
  
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
    pointer-events: none;
  }
  
  &:hover::after {
    transform: translateX(100%);
  }
}

// Checkbox and Radio animations
.el-checkbox__inner,
.el-radio__inner {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  &:hover {
    transform: scale(1.1);
  }
}

.el-checkbox__input.is-checked .el-checkbox__inner {
  animation: checkboxBounce 0.4s ease;
}

.el-radio__input.is-checked .el-radio__inner {
  animation: radioPop 0.4s ease;
}

// Switch animation
.el-switch__core {
  position: relative;
  overflow: hidden;
  
  &::after {
    content: '';
    position: absolute;
    top: 50% !important;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: translateY(-50%);
    transition: left 0.5s;
  }
  
  // &:hover::after {
  //   left: 100%;
  // }
}

// Tab transitions
.el-tabs__item {
  position: relative;
  
  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: $primary-color;
    transform: translateX(-50%);
    transition: width 0.3s ease;
  }
  
  &:hover::after {
    width: 100%;
  }
  
  &.is-active {
    animation: tabActivate 0.3s ease;
  }
}

// Dropdown menu animations
.el-dropdown-menu__item {
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: $primary-color;
    transform: scaleY(0);
    transition: transform 0.3s ease;
  }
  
  &:hover::before {
    transform: scaleY(1);
  }
}

// Select option animations
.el-select-dropdown__item {
  transition: all 0.3s ease;
  
  &:hover {
    padding-left: 24px;
    
    &::before {
      content: '▸';
      position: absolute;
      left: 8px;
      color: $primary-color;
      animation: slideRight 0.3s ease;
    }
  }
}

// Tag animations
.el-tag {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  &:hover {
    transform: scale(1.05) rotate(-2deg);
  }
  
  &.el-tag--closable {
    .el-tag__close {
      transition: all 0.3s ease;
      
      &:hover {
        transform: rotate(90deg);
        color: $danger-color;
      }
    }
  }
}

// Loading spinner enhancement
.el-loading-spinner {
  .circular {
    animation: rotate 2s linear infinite, scale 1.5s ease-in-out infinite;
  }
}

// Message notification entrance
.el-message {
  animation: messageSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  &.el-message-fade-leave-active {
    animation: messageSlideOut 0.3s ease;
  }
}

// Tooltip enhancement
.el-tooltip__popper {
  animation: tooltipFadeIn 0.2s ease;
}

// Progress bar animation
.el-progress-bar__inner {
  position: relative;
  
  &::after {
    animation: progressShine 2s linear infinite;
  }
}

// Animations
@keyframes buttonPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes buttonShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

@keyframes inputGlow {
  0% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4); }
  100% { box-shadow: 0 0 0 6px rgba(74, 144, 226, 0); }
}

@keyframes checkmark {
  0% { transform: scale(0) rotate(45deg); }
  50% { transform: scale(1.2) rotate(45deg); }
  100% { transform: scale(1) rotate(45deg); }
}

@keyframes checkboxBounce {
  0% { transform: scale(1); }
  33% { transform: scale(0.9); }
  66% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes radioPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes tabActivate {
  0% { transform: translateY(2px); }
  50% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

@keyframes slideRight {
  from { transform: translateX(-10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes messageSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes messageSlideOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-20px);
    opacity: 0;
  }
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes progressShine {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes scale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

// Ripple effect for buttons
@mixin ripple-effect {
  position: relative;
  overflow: hidden;
  
  &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
  }
  
  &:focus:not(:active)::after {
    animation: ripple 1s ease-out;
  }
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  20% {
    transform: scale(25, 25);
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: scale(40, 40);
  }
}

// Apply ripple to buttons
.el-button {
  @include ripple-effect;
}

// Floating label effect
.form-group {
  position: relative;
  
  .floating-label {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    background: white;
    padding: 0 5px;
    color: $text-secondary;
    transition: all 0.3s ease;
    pointer-events: none;
  }
  
  .el-input__inner:focus + .floating-label,
  .el-input__inner:not(:placeholder-shown) + .floating-label {
    top: -8px;
    font-size: 12px;
    color: $primary-color;
  }
}